<?php

namespace App\Http\Controllers\Admin;

use App\Models\Admin\Admins;
use App\Models\Admin\Users;
use App\Models\Api\Fishmonger;
use App\Models\Api\Merchant;
use Illuminate\Support\Facades\Redis;
use Illuminate\Http\Request;

class IndexController extends BaseController
{
    /**
     * 首页
     * @param Request $request
     */
    public function index(Request $request)
    {
        $data['admin'] = Admins::where('id', $this->user['uid'])->first();
        return view('Admin/Index/index', $data);
    }

    /**
     * @param Request $request
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
     */
    public function panel(Request $request)
    {
        $data['user'] = Users::count();
        $user_report = Users::getReport(['start_time' => date("Y-m-d", strtotime(date('Y-m-d')) - (60 * 60 * 24 * 6)), 'end_time' => date('Y-m-d')]);
        $data['user_report'] = $user_report['code'] == 200 ? json_encode($user_report['data']) : json_encode([]);

        return view('Admin/Index/panel', $data);
    }

}